home *** CD-ROM | disk | FTP | other *** search
/ Aminet 14 / Aminet 14 - Oct 1996.iso / TCalc / Deutsch / TurboCalc3.5Demo / Programmer / Examples.lha / demo_function.tclib.s next >
Text File  |  1994-11-10  |  3KB  |  121 lines

  1. *********************************************
  2. ** Example for a very simple 'external funtions' class.
  3. ** For a description of the implemented functions/macors see
  4. ** the included TurboCalc-Sheet 'Fkt_TCLibs.TCD'
  5. **
  6. ** (c) 1994 by Michael Friedrich
  7. ** All Rights Reserved.
  8. **
  9. ** You may use parts of this code to create your own private TCLibs.
  10. ** You are also allowed to publish these TCLibs as long as I will get
  11. ** a copy them.
  12. **
  13.  
  14.     include "tclib.i"
  15.  
  16. startall:
  17.     moveq   #-13,d0     ; if user tries to start this lib!
  18.     rts                 ;   (need -13 to identify TClibs!)
  19.     dc.l 'TCLB'         ; TurboCalc-Lib - this field is used to identify
  20.                         ;   TClibs and to link them in memory (i.e. that
  21.                         ;   this entry is used and thus changed by TC
  22.                         ;   to keep a list of all already loaded libs!)
  23.     dc.l 'FNCT'
  24.     dc.w 1,0            ; Version, Revision
  25.     dc.l txt_name
  26.     dc.l txt_ver
  27.     dc.l txt_author
  28.     dc.l 0              ; flags - reserved
  29.     dc.l 0              ; reserved
  30.     dc.l 0              ; reserved
  31. * default-routines
  32.     dc.l 0  ; init
  33.     dc.l 0  ; exit
  34.     dc.l 0  ; flush
  35.     dc.l 0
  36. *
  37.     dc.l 0  ; flags
  38.     dc.l 5
  39.     dc.l demo_fncdefault
  40.     dc.l demo_function1
  41.     dc.l demo_function2
  42.     dc.l demo_function3
  43.     dc.l demo_function4
  44.     dc.l demo_function5
  45.  
  46.  
  47. txt_name: dc.b 'Function/Macro-TCLib Example',0
  48. txt_ver: dc.b '$VER: SimpleFunctions V1.0 (01.11.94)',0
  49. txt_author: dc.b '© 1994 Michael Friedrich',0
  50.  cnop 0,2
  51.  
  52.  
  53. *** unknown function - simply return function-number as init!
  54. demo_fncdefault:
  55.     move.l  d7,d0
  56.     moveq   #TYPE_NUM,d2
  57.     rts
  58.  
  59. *** val1+val (as long)
  60. demo_function1:
  61.     move.l  d2,d0
  62.     add.l   d5,d0
  63.     moveq   #TYPE_NUM,d2
  64.     rts
  65. *** val1*val2 (as long)
  66. demo_function2:
  67.     move.l  d2,d0
  68.     mulu    d5,d0
  69.     moveq   #TYPE_NUM,d2
  70.     rts
  71. *** val1*val (as float)
  72. demo_function3:
  73.     moveq   #CDX_Mul,d7
  74.     XSR     Call_CDX
  75.     moveq   #TYPE_FLOAT,d2
  76.     rts
  77. *** uppercase(text) - starting at val1, max. val2 chars (0=all)!
  78. demo_function4:
  79.     move.l  a0,d0
  80.     beq.s   90$
  81.     XSR     DuplicateTEXT
  82.     move.l  a0,d0
  83.     beq.s   90$
  84. * skip first part
  85.     subq.w  #2,d2
  86.     bmi.s   22$
  87. 20$ tst.b   (a0)+
  88.     beq.s   90$
  89. 21$ dbra    d2,20$
  90. 22$
  91. *
  92.     subq.w  #1,d5
  93.     move.l  d0,d2
  94. 30$ move.b  (a0),d0
  95.     beq.s   39$
  96.     XSR     UpperCaseD0
  97.     move.b  d0,(a0)+
  98.     dbra    d5,30$
  99. 39$ move.l  d2,d0
  100. *
  101. 90$ moveq   #TYPE_TEXT,d2
  102.     rts
  103.  
  104. ******************************
  105. demo_function5: ; it's a macro!
  106. * simple macro, blinking the LED.
  107. 10$ move.l  d5,d0
  108.     bchg    #1,$bfe001
  109. 20$ subq.l  #1,d0
  110.     bpl.s   20$
  111.     subq.l  #1,d2
  112.     bpl.s   10$
  113.     moveq   #0,d0
  114.     moveq   #TYPE_NUM,d2
  115.     rts
  116.  
  117.  
  118.  
  119.  
  120.         END
  121.